<?php
namespace Modules\Captcha;

use Phalcon\DiInterface;

class Module implements \Phalcon\Mvc\ModuleDefinitionInterface {
  public function registerAutoloaders(DiInterface $di = null) {
    (new \Phalcon\Loader()) -> registerNamespaces([
      'Gregwar\\Captcha' => APPLICATION_ROOT_DIR . '/vendor/gregwar/captcha/src/Gregwar/Captcha',

      __NAMESPACE__ . '\\Controllers' => __DIR__ . '/controllers/',
    ]) -> register();
  }

  public function registerServices(DiInterface $di) {
    $di -> set('dispatcher', function() {
      $dispatcher = new \Phalcon\Mvc\Dispatcher();
      $dispatcher -> setDefaultNamespace(__NAMESPACE__ . '\\Controllers');
      return $dispatcher;
    });

    $di -> set('view', function () {
      return (new \Phalcon\Mvc\View()) -> disable();
    });

    $di -> set('session', function() {
      $session = new \Phalcon\Session\Adapter\Files();
      $session -> start();
      return $session;
    });

  }
}
